#include "TcpServer.hpp"
#include "Log.hpp"
#include "Command.hpp"
#include <memory>

using namespace log_ns;

int main(int argc, char *args[])
{
    if (argc != 2)
    {
        LOG(FATAL, "Usage: ./tcpserver -localport\n");
        exit(0);
    }
    uint16_t port = std::stoi(args[1]);
    Command cmd;
    std::unique_ptr<TcpServer> tcsv = std::make_unique<TcpServer>(
        std::bind(&Command::HandlerCommand,
                  &cmd, std::placeholders::_1,
                  std::placeholders::_2),
        port);
    tcsv->InitServer();
    tcsv->Loop();

    return 0;
}